package io;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
/**
 * 将message.txt文件中的内容进行反序列化
*/
public class ObjectInputStreamDemo02 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //1.创建流对象
        ObjectInputStream ois=
                  new ObjectInputStream(
                           new FileInputStream("message.txt"));//FileNotFoundException
        //2.读取对象(反序列化-先读出来的是字节，然后将字节转换对象)
        Message msg=(Message)ois.readObject();//IOException,ClassNotFoundException
        System.out.println(msg);
        //3.关闭资源
        ois.close();
    }
}
